{extend name="public/base"}

{block name="body"}
<div class="pageControl partner">
    <div class="di"></div>
    <div class="msui_nav msui_navTop">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">邀请合伙人</h1>
    </div>
    <div class="weui-top">
        <div class="partner-count">
            <p class="cl-3333 fs09">我的邀请码: <span class="cl-fb4" id="copy">{$data.invitation_code}</span></p>
            <a href="javascript:;" class="partner-link cl3db fs085 bar" data-clipboard-action="cut" data-clipboard-target="#copy">复制邀请码</a>
            <p class="partner-count-a">已成功邀请 <span class="cl-fb4">{$data.invitation_partners_num}</span>人,获得奖励 <span class="cl-fb4">{$data.invitation_partners_total}</span>元</p>
        </div>
        <div class="partner-main">
            <div class="menu_list" >
                <!--导航-->
                <ul class="coupons_ul">
                    <li dataTab="1" class="fs08 msui_tabMenu-active">邀请明细</li>
                    <li dataTab="2" class="fs08 ">活动说明</li>
                </ul>
            </div>
            <div class="menu_page">
                <div dataPage="1" class="js-list">
                    <div class="partner-title">
                        <span>邀请奖励明细</span>
                    </div>
                    <div class="partner-table">
                        <div class="partner-ul">
                            <ul class="list-head">
                                <li>被邀请人</li>
                                <li>加盟等级</li>
                                <li>邀请奖励</li>
                            </ul>
                            {volist name="data.can_invitation" id="vo"}
                            <ul class="list-head">
                                <li>{$vo.proposer}</li>
                                <li>{$vo.level|get_level}</li>
                                <li class="list1">
                                    <span>{$vo.money}</span>
                                    {eq name="vo.get_status" value="1"}
                                    <a href="javascript:;" class="partner-btn">已领取</a>
                                    {else /}
                                    <a href="javascript:;" class="partner-btn get" data-id="{$vo.id}">领取</a>
                                    {/eq}
                                </li>
                            </ul>
                            {/volist}
                        </div>
                    </div>
                    <div class="partner-title">
                        <span>我的邀请记录</span>
                    </div>
                    <div class="partner-table partner-table1">
                        <div class="partner-ul">
                            <ul class="list-head">
                                <li>被邀请人</li>
                                <li>申请时间</li>
                                <li>审核状态</li>
                            </ul>
                            {volist name="data.invitation_partners" id="vo"}
                            <ul class="list-head">
                                <li>{$vo.proposer}</li>
                                <li>{$vo.apply_time|date="Y-m-d", ###}</li>
                                <li class="list1">
                                    {gt name="vo.audit_time" value="0"}<span>{$vo.audit_time|date="Y-m-d", ###}</span>{/gt}
                                    {eq name="vo.audit_status" value="1"} <span class="pass">已申请</span>{/eq}
                                    {eq name="vo.audit_status" value="2"} <span class="pass">通过</span>{/eq}
                                    {eq name="vo.audit_status" value="3"} <span class="pass">未通过</span>{/eq}
                                    {eq name="vo.audit_status" value="4"} <span class="pass">关闭</span>{/eq}
                                </li>
                            </ul>
                            {/volist}
                        </div>
                    </div>
                </div>
                <div dataPage="2"  class="js-list"  style="display: none;">
                    <div class="partner-title">
                        <span>邀请奖励说明</span>
                    </div>
                    <div class="partner-hd">
                        <div class="weui-cell">
                            <div class="weui-label">
                                <span class="step">1</span>
                                <i class="step1"></i>
                            </div>
                            <div class="weui-cell__bd">
                                <p>获取您的邀请码。</p>
                            </div>
                        </div>
                        <div class="weui-cell">
                            <div class="weui-label"><span class="step">2</span></div>
                            <div class="weui-cell__bd">
                                <p>分享邀请码给其他合伙人。</p>
                            </div>
                        </div>
                        <div class="weui-cell">
                            <div class="weui-label"><span class="step">3</span></div>
                            <div class="weui-cell__bd">
                                <p>其他合伙人使用您的邀请码申请认证。</p>
                            </div>
                        </div>
                        <div class="weui-cell">
                            <div class="weui-label">
                            <span class="step">4
                                <i class="step2"></i>
                            </span>
                            </div>
                            <div class="weui-cell__bd">
                                <p>其他合伙人认证成功后，你可以领取邀请奖励。</p>
                            </div>
                        </div>
                        <div class="weui-cell">
                            <div class="weui-label1"></div>
                            <div class="weui-cell__bd">
                                <p>被邀请合伙人，审核通过后，并且在规定时间内(如一个月)不退出(即不被关闭)，且有邀请新的合伙人或下级分销用户，邀请人就可以获得邀请奖励 。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

{/block}

{block name="javascript"}
{js href="/static/wechat/js/clipboard.min.js" /}
<script>
    var clipboard= new Clipboard('.bar');
    clipboard.on('success', function(e) {
        console.info('Action:', e.action);
        console.info('Text:', e.text);
        console.info('Trigger:', e.trigger);
        e.clearSelection();
    });
    clipboard.on('error', function(e) {
        console.error('Action:', e.action);
        console.error('Trigger:', e.trigger);
    });

    $('.partner .menu_list li').on('click',function(){
        var dataTab=$(this).attr('dataTab');
//	console.log($(this));
        var that=this;
        $('.partner .menu_list li').each(function(){
            if($(this).hasClass('msui_tabMenu-active')){
                $(this).removeClass('msui_tabMenu-active');
            }
            $(that).addClass('msui_tabMenu-active');
        })
        $('.partner .js-list').each(function(){
            $(this).css('display','none');
            if($(this).attr('dataPage')==$(that).attr('dataTab')){
                $(this).css('display','block');
            }
        })
    });
    $(".get").click(function(e){
        e.preventDefault();
        if (!confirm('确认领取奖励？')) {
            return false;
        }
        var _this = $(this);
        var id = _this.data('id');
        $.ajax({
            type : 'POST',
            url : '?',
            data : {
                'invitation_partner_id' : id
            },
            dataType : 'json',
            success : function (msg) {
                if (msg.code == 200) {
                    _this.addClass('active').html('已领取')
                } else{
                    var code = msg.code;
                    $.alert(error_code[code]);
                }
            }
        });
    });
</script>
{/block}